package com.coderush.admin.sys.dao;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.coderush.admin.sys.mapper.RoleMapper;
import com.coderush.admin.sys.model.entity.Role;
import com.coderush.admin.sys.model.vo.RolePageVo;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Repository;

/**
 * PackageName com.coderush.admin.sys.dao
 *
 * @Author Eason
 * @Version v1.0
 * @ClassName RoleDao
 * @Date 2025/8/29
 * @Description TODO
 */
@Repository
public class RoleDao {

    @Resource
    private RoleMapper roleMapper;

    /**
     * 根据公司ID和角色名称查询角色信息
     */
    public Role getByRoleName(String roleName) {
        return roleMapper.getByRoleName(roleName);
    }

    /**
     * 根据公司ID和角色编码查询角色信息
     */
    public Role getByRoleCode(String roleCode) {
        return roleMapper.getByRoleCode(roleCode);
    }

    /**
     * 根据ID删除
     */
    public Boolean deleteById(Role  role) {
        return roleMapper.deleteById(role) > 0;
    }

    /**
     * 修改角色信息
     */
    public Boolean update(Role role) {
        return roleMapper.updateById(role) > 0;
    }

    /**
     * 添加角色信息
     */
    public Boolean add(Role role) {
        return roleMapper.insert(role) > 0;
    }

    /**
     * 根据角色ID查询角色信息
     */
    public Role getById(Long id) {
        return roleMapper.selectById(id);
    }

    public Page<Role> findRolePage(Page<Role> page, String roleName) {
        return roleMapper.findRolePage(page, roleName);
    }
}